package com.vieewer.btdemo.app

import android.app.Activity
import android.app.Application
import android.os.Build
import com.lindroid.androidutilskt.app.AndUtil
import com.youngfeng.snake.Snake
import com.vieewer.btdemo.common.MyActivityManager
import android.os.Bundle
import android.support.v4.app.ActivityCompat


/**
 * @author yjj
 * @date 2019/9/27
 * @function
 * @Description
 */
class App : Application() {

    companion object {
        lateinit var instance: App
    }

    init {
        instance = this
    }

    override fun onCreate() {
        super.onCreate()
        // 对Snake进行初始化
        Snake.init(this)
        AndUtil.init(this)
            .setLogGlobalConfig {
                setLogEnable(true)
                setMethodCount(2)
            }
//            .setDefaultSpFile()     //设置SharePreferences的默认表名，默认为“sp_util”
//            .setServerTimeFormat()  //设置时间格式化中服务器时间格式，默认为“yyyy-MM-dd'T'HH:mm:ss.SSS”


        registerActivityLifecycleCallbacks(object : ActivityLifecycleCallbacks {
            override fun onActivityPaused(p0: Activity?) {

            }

            override fun onActivityResumed(p0: Activity?) {

                MyActivityManager.getInstance().currentActivity = p0

            }

            override fun onActivityStarted(p0: Activity?) {

            }

            override fun onActivityDestroyed(p0: Activity?) {

            }

            override fun onActivitySaveInstanceState(p0: Activity?, p1: Bundle?) {

            }

            override fun onActivityStopped(p0: Activity?) {

            }

            override fun onActivityCreated(p0: Activity?, p1: Bundle?) {

            }

        })




    }



    




}